#include "util.h"
#include "flash.h"
#include <string.h>

uint8 __xdata *pInformation = (uint8 __xdata *)0x780C;
//INT32 SecondaryIEEE = 0x3FFE8;
INT32 SecondaryIEEE = 0x38000;
char set_addr[8] = {0x01, 0xFF, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00};
//INT32 LockBit = 0x20000;


void demo_app()
{
#if 1
	char addr[8] = {0}, lockbit[24];
	uint8 i;

#if 0	
	FlashRead(LockBit , (BYTE *)lockbit + 8, 16);
	TRACE("LockBit: ");
	for(i = 0; i < 16; i++)
		TRACE("%02x ", lockbit[i]);
	TRACE("\r\n");
#endif	
	memcpy(lockbit, set_addr, 8);

	
	FlashErase(SecondaryIEEE);
	FlashWrite((BYTE *)lockbit, SecondaryIEEE, 24);
	FlashRead(SecondaryIEEE, addr, sizeof(addr));
	TRACE("SecondaryIEEE IEEE Address: ");
	for(i = 0; i < 8; i++)
		TRACE("%02x ", addr[i]);
	TRACE("\r\n");
	
	TRACE("Primary IEEE Address: ");
	for(i = 0; i < 8; i++)
		TRACE("%02x ", pInformation[i]);
	TRACE("\r\n");
	
	while(1)
	{
		halMcuWaitMs(1000);
		TRACE("Hello\r\n");
	};
#endif
	
}